package br.com.covosys.model;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import br.com.covosys.dao.GenericDAO;

public interface GenericModel<BEAN extends Serializable, DAO extends GenericDAO<BEAN>> extends Serializable {
	
	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public void save(BEAN bean) throws ModelException;
	
	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public void delete(BEAN bean) throws ModelException;
	
	@Transactional(propagation = Propagation.SUPPORTS, isolation = Isolation.READ_COMMITTED)
	public BEAN retrieve(BEAN bean) throws ModelException;

	@Transactional(propagation = Propagation.SUPPORTS, isolation = Isolation.READ_COMMITTED)
	public List<BEAN> list() throws ModelException;
	
	@Transactional(propagation = Propagation.SUPPORTS, isolation = Isolation.READ_COMMITTED)
	public List<BEAN> list(Map<String, Object> parametros) throws ModelException;	
}